package concurrency;

class Car {
    private final int mId;

    private boolean mEngine = false;

    /**
     * 动力传动系统
     */
    private boolean mDriveTrain = false;

    private boolean mWheels = false;

    public Car(int id) {
        mId = id;
    }

    /**
     * Empty Car object:
     */
    public Car() {
        mId = -1;
    }

    public synchronized void addEngine() {
        mEngine = true;
    }

    public synchronized void addDriveTrain() {
        mDriveTrain = true;
    }

    public synchronized void addWheels() {
        mWheels = true;
    }

    @Override
    public String toString() {
        return "Car_" + mId + " [" + "engine: " + mEngine
               + " driveTrain: " + mDriveTrain
               + " wheels: " + mWheels + "]";
    }
}
